home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / etc_-_Configuration_Files / PCMCIA / SERIAL < prev    next >
Text File  |  1999-09-17  |  2KB  |  90 lines

  1. #!/bin/sh
  2. #
  3. # serial 1.29 1998/10/08 19:44:28 (David Hinds)
  4. #
  5. # Initialize or shutdown a PCMCIA serial device
  6. #
  7. # The first argument should be either 'start' or 'stop'.  The second
  8. # argument is the base name for the device.
  9. #
  10. # The script passes an extended device address to 'serial.opts' in the 
  11. # ADDRESS variable, to retrieve device-specific configuration options.
  12. # The address format is "scheme,socket,instance" where "scheme" is the
  13. # PCMCIA configuration scheme, "socket" is the socket number, and
  14. # "instance" is used to number multiple ports on a single card.  
  15. #
  16.  
  17. if [ -r ./shared ] ; then . ./shared ; else . /etc/pcmcia/shared ; fi
  18.  
  19. # Get device attributes
  20. get_info $DEVICE
  21.  
  22. # Load site-specific settings
  23. ADDRESS="$SCHEME,$SOCKET,$INSTANCE"
  24. . $0.opts
  25.  
  26. # Newer kernels do not have "cua" devices
  27. if [ -c /dev/cua1 ] ; then
  28.     NR=`expr $MINOR - 64`
  29.     DIALOUT=cua$NR
  30. else
  31.     DIALOUT=$DEVICE
  32. fi
  33.  
  34. case "$ACTION" in
  35.  
  36. 'start')
  37.     if [ ! -c /dev/$DEVICE -o ! -c /dev/$DIALOUT ] ; then
  38.     cd /dev
  39.     ./MAKEDEV $DEVICE
  40.     fi
  41.     if [ "$LINK" ] ; then
  42.     mv -f $LINK $LINK.O 2>/dev/null
  43.     ln -s /dev/$DIALOUT $LINK
  44.     fi
  45.     if [ "$SERIAL_OPTS" ] ; then
  46.     setserial /dev/$DEVICE $SERIAL_OPTS
  47.     fi
  48.     if [ "$INITTAB" ] ; then
  49.     echo "S$NR:12345:respawn:$INITTAB $DEVICE" >> /etc/inittab
  50.     telinit q
  51.     fi
  52.     ;;
  53.  
  54. 'check')
  55.     fuser -s /dev/$DEVICE /dev/$DIALOUT $LINK && exit 1
  56.     ;;
  57.  
  58. 'cksum')
  59.     chk_simple "$3,$SOCKET,$INSTANCE" || exit 1
  60.     ;;
  61.     
  62. 'stop')
  63.     if [ "$INITTAB" ] ; then
  64.     fgrep -v $DEVICE /etc/inittab > /etc/inittab.new
  65.     mv /etc/inittab.new /etc/inittab
  66.     telinit q
  67.     fi
  68.     fuser -s -k /dev/$DEVICE /dev/$DIALOUT $LINK
  69.     rm -f $LINK ; mv -f $LINK.O $LINK 2>/dev/null
  70.     ;;
  71.  
  72. 'suspend')
  73.     fuser -s -k -STOP /dev/$DEVICE /dev/$DIALOUT
  74.     ;;
  75.  
  76. 'resume')
  77.     if [ "$SERIAL_OPTS" ] ; then
  78.     setserial /dev/$DEVICE $SERIAL_OPTS
  79.     fi
  80.     fuser -s -k -CONT /dev/$DEVICE /dev/$DIALOUT $LINK
  81.     ;;
  82.  
  83. *)
  84.     usage
  85.     ;;
  86.  
  87. esac
  88.  
  89. exit 0
  90.